package com.fys.markbook.action

import com.fys.markbook.dialog.AddNoteDialog
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.ui.EditorTextField

/**
 * @Title: MBPopAction
 * @Description: 添加到笔记列表 添加后数据操作
 * @Author: fanyushuai
 * @Date: 2023/9/6 10:40
 * @Version V1.0
 */
class MBPopAction : AnAction() {
    override fun actionPerformed(e: AnActionEvent) {
        // TODO: insert action logic here
        println("添加笔记被点击了")

        //获取当前编辑器对象
        val editor = e.getRequiredData(CommonDataKeys.EDITOR);
        //获取选择的数据模型
        val selectionModel = editor.selectionModel;
        //获取当前选择的文本
        val selectedText = selectionModel.selectedText;

        val etfMark = EditorTextField("$selectedText");
        val addNoteDialog = AddNoteDialog(etfMark);
        addNoteDialog.show();
        //println("selected:$selectedText");
    }
}
